package com.example.taobaounion.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {
    private Unbinder mBind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResId());
        mBind = ButterKnife.bind(this);
        initView();
        initEvent();
        initPresenter();
        //设置清明节UI
        // //设置它的饱和度为0
        // ColorMatrix cm = new ColorMatrix();
        // cm.setSaturation(0);
        // Paint paint = new Paint();
        // paint.setColorFilter(new ColorMatrixColorFilter(cm));
        // //拿到最顶部的容器
        // View contentContainer = this.getWindow().getDecorView();
        // //修改容器的画笔
        // contentContainer.setLayerType(View.LAYER_TYPE_SOFTWARE,paint);
    }

    protected abstract void initPresenter();

    /**
     * 子类需要的时候重写
     */
    protected void initEvent() {

    }


    protected abstract void initView();


    //抽象类的抽象方法子类必须继承
    protected abstract int getLayoutResId();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mBind != null) {
            mBind.unbind();
        }
        release();
    }

    /**
     * 如果子类需要释放资源，就复写该方法
     */
    protected void release() {

    }
}
